/*
 * 版权所有 (C) 2001-2014 深圳市艾派应用系统有限公司。保留所有权利。
 * 版本：
 * 修改记录：
 *		1、Sep 24, 2014，Administrator创建。 
 */
package com.cmcc.aregister.ui.adapter;

import java.util.List;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.model.Schedule;

public class DoctorDetailAdapter extends BaseAdapter {

    private Context mContext;
    private List<Schedule> list;

    public DoctorDetailAdapter(Context context, List<Schedule> schedule_list) {
        this.mContext = context;
        this.list = schedule_list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int arg0) {
        return list.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup arg2) {
        ViewHolder viewHolder = null;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(
                R.layout.item_doctor_detail, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_to_date = (TextView) view
                .findViewById(R.id.tv_doctor_detail_to_date);
            viewHolder.tv_time_type = (TextView) view
                .findViewById(R.id.tv_doctor_detail_time_type);
            viewHolder.tv_left_num = (TextView) view
                .findViewById(R.id.tv_doctor_detail_left_num);
            view.setTag(viewHolder);
        }
        else {
            viewHolder = (ViewHolder) view.getTag();
        }
        Schedule sch = list.get(position);
        viewHolder.tv_to_date.setText(sch.to_date);
        viewHolder.tv_time_type.setText(sch.time_type);
        viewHolder.tv_left_num.setText(Html.fromHtml(mContext
            .getString(R.string.left_num) + "<font color=red>" + sch.left_num + "</font>"));
        return view;
    }

    private class ViewHolder {
        private TextView tv_to_date, tv_time_type, tv_left_num;
    }

}